I have a news site in ASP.NET MVC, where all the data comes from the homepage of the database. And this is generating a large traffic to my hosting server.
I have sessions like: Politics, Sports, World, among others, and each session is a different request made to the database. But each request only a small number of data is returned from the database, maximum 8 results for query. In total there are 21 requests made to the database.
I thought about making a data.json file and persist the session information in this file and show them in the frontend.
But as the file data.json and not a database, I have to do all the work to relocate the information when an action to delete or edit is performed.
Is there a better way to get to the point I want, considering that the site is already published?
Norman Reedus
03-Nov-2014I would put a caching layer in between the site and the db so when you do one of these calls to the db it first checks the cache to see if the objects are there, if they are then it returns them from memory (super quick), if not it gets from db and populates the cache for next time. You must remember to clear the cache when the data in the DB gets changed though.
Cache Interface:
Cache Implementation:
Usage: